<?php e($html->css('bug', 'stylesheet')); ?>
<div class="bugs index" style="width: 90%">
<h2><?php __('Bugs & Suggests');?></h2>
<!-- Separate bugs into two groups -->
<?php
$pending = $resolved = array();
foreach($bugs as $i=>$bug){
    if($bug['Bug']['resolved']){
        array_push($resolved, $bug);
    }else{
        array_push($pending, $bug);
    }
}
unset($bugs);
?>
<!-- Print tabs -->
<ul class="tabs">
    <li><a href="javascript:void(0)"><?php __('Resolved'); ?></a></li>
    <li><a href="javascript:void(0)"><?php __('Pending'); ?></a></li>
    <li><a href="javascript:void(0)"><?php __('My Sugguestions'); ?></a></li>
</ul>
<div class="panes">
    <!-- Resolved bugs -->
    <div class="resolved bugs">
        <?php foreach($resolved as $i=>$bug): $class = $i % 2 != 0 ? ' altrow' : ''; ?>
            <div class="bug<?php e($class); ?>">
                <p class="meta">
                    <?php __('Submitted on'); ?>
                    <span class="created"><?php e($time->format($options['dateFormat'], $bug['Bug']['created'])); ?></span>
                    <?php __('By'); ?>
                    <strong class="reporter"><?php e($bug['Bug']['reporter']); ?></strong>
                    <!-- Bug delete or resolve link for root users -->
                    <?php if(isset($user['group']) && ($user['group'] == 'root')): ?>
                        &nbsp;&nbsp;&nbsp;
                        <?php e($html->link(__('Delete', true), array('action'=>'delete', $bug['Bug']['id']))); ?>
                    <?php endif; ?>
                </p>
                <p class="content"><?php e($bug['Bug']['content']); ?></p>
            </div>
        <?php endforeach; ?>
    </div>
    <!-- Pending bugs -->
    <div class="pending bugs">
        <?php foreach($pending as $i=>$bug): $class = $i % 2 != 0 ? ' altrow' : ''; ?>
            <div class="bug<?php e($class); ?>">
                <p class="meta">
                    <?php __('Submitted on'); ?>
                    <span class="created"><?php e($time->format($options['dateFormat'], $bug['Bug']['created'])); ?></span>
                    <?php __('By'); ?>
                    <strong class="reporter"><?php e($bug['Bug']['reporter']); ?></strong>
                    <!-- Bug delete or resolve link for root users -->
                    <?php if(isset($user['group']) && ($user['group'] == 'root')): ?>
                        &nbsp;&nbsp;&nbsp;
                        <?php e($html->link(__('Delete', true), array('action'=>'delete', $bug['Bug']['id']))); ?>
                        &nbsp;&nbsp;&nbsp;
                        <?php e($html->link(__('Resolve', true), array('action'=>'resolve', $bug['Bug']['id']))); ?>
                    <?php endif; ?>
                </p>
                <p class="content"><?php e($bug['Bug']['content']); ?></p>
            </div>
        <?php endforeach; ?>
    </div>
    <!-- Suggestion Form -->
    <div class="bugs form">
        <?php echo $form->create('Bug', array('controller'=>'bugs', 'action'=>'add', 'type'=>'file'));?>
            <fieldset>
                <?php $reporter = empty($user['username']) ? 'guest' : $user['username']; ?>
                <?php e($form->hidden('reporter', array('value'=>$reporter))); ?>
                <p class="faq">
                    <?php __('Put your bad experience or sugguestions here then click the submit button'); ?>
                    如果您希望系统提供某些功能, 尽可直言, 我们的工作因为您的需要而变的有价值!
                </p>
                <?php e($form->input('content',array('label'=>false,'class'=>'textarea', 'type'=>'textarea'))); ?>
                <?php e($form->Submit(__('Submit', true), array('class'=>'submit attention'))); ?>
            </fieldset>
        <?php echo $form->end();?>
    </div>
</div>

</div>

<?php //debug($bugs); //debug($pending); debug($resolved); ?>
<script type="text/javascript">
jQuery(function(){
    $('ul.tabs').tabs('div.panes div.bugs');
});
</script>